package com.newlink.building.userinfo.mvp

import com.newlink.building.common_base.base.BasePresenter
import com.newlink.building.common_base.ext.ss
import com.newlink.building.common_base.utils.logDebug
import com.newlink.building.userinfo.mvp.contract.Module_UserInfo_FlsMsgContract
import com.newlink.building.userinfo.mvp.model.Module_UserInfo_FlsMsgModel

/**
 * @Author: Jake
 * @Date: 2023-12-11
 * @Description:
 */
class Module_UserInfo_FlsMsgPresenter : BasePresenter<Module_UserInfo_FlsMsgContract.Model, Module_UserInfo_FlsMsgContract.View>(),
    Module_UserInfo_FlsMsgContract.Presenter {

    override fun createModel(): Module_UserInfo_FlsMsgContract.Model? {
        return Module_UserInfo_FlsMsgModel()
    }

    override fun deleteAllFlsMessageList(token: String, userId: String) {
        mModel?.deleteAllFlsMessageList(token, userId)?.ss(mModel, mView) { response ->
            logDebug<Module_UserInfo_FlsMsgPresenter>("删除所有消息列表 response - $response")
            response?.let {
                if (it.code == 200) {
                    mView?.deleteAllMessageListSuccess()
                } else {
                    mView?.deleteAllMessageListFail()
                }
            }
        }
    }

    override fun getFlsMessageList(token: String, userId: String, page: Int, limit: Int) {
        mModel?.getFlsMessageList(token, userId, page, limit)?.ss(mModel, mView) { response ->
            logDebug<Module_UserInfo_FlsMsgPresenter>("获取消息列表 response - $response")
            response?.let {
                if (it.code == 200) {
                    mView?.getFlsMessageListSuccess(it.data.list)
                } else {
                    mView?.getFlsMessageListFail()
                }
            }

        }
    }

}